import { createService } from "../request"
const rq = createService('/myapi')

// 获取商品分类列表
export function getCategoryList(page, params, config) {
    return rq.get(`/admin/category/${page}`, { params }, config)
}

// 新增商品分类
export function addCategory(form, config) {
    return rq.post('/admin/category', form, {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

// 修改商品分类
export function updateCategoryById(form, config) {
    return rq.post(`/admin/category/${form.id}`, form, {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
}

// 删除商品分类
export function deleteCategoryById(id, config) {
    return rq.post(`/admin/category/${id}/delete`, null, config)
}

// 修改商品分类状态
export function updateCategoryStatusById(id, status, config) {
    return rq.post(`/admin/category/${id}/update_status`, { status }, config)
}
